They have to be wood. Attach to wall with brackets or screw back to wall. Need to make sure the sides are firmly attached to back.
Here are some good ideas: https://homebnc.com/best-diy-wood-crate-shelves-ideas/
I agree with Kelli
Hi Julie, Crates make great shelving with something as simple as zip ties to connect them. You did not say what type of boxes you are using, wooden ones would do the same as the plastic crates. Paint them or leave them "rustic" depending on your decor in the home.
I've used apple crates, old drawers and wine crates all as shelves, ensure you have good fittings when screwing to the wall.
Here's a crate shelving tutorial: https://www.youtube.com/watch?v=bWL3ux6QKn4