It can be done both ways! The benefit of installing the shelves before tile is that you can avoid drilling into the tile. The tile will also hide any uneven gaps along the wall. However, this makes tiling slightly more difficult as you'll have to cut it to fit around the shelves.