In order to get on top of the Gizmo Shop you need to already beat Traverse Town the 1st time and go through the ring of worlds including Wonderland, Deep Jungle, and Olympus Coliseum. Then you should return to Traverse Town for a 2nd visit and complete a few side-missions.
The Gizmo Shop roof is only accessible through a ladder out the back exit. When you first visit Traverse Town this ladder will be broken and unusable. However it is repaired by your 2nd visit and it will stay fixed from that point onward.
The roof contains a Trinity mark which opens access to a bell you need to ring 3 times. This will unlock the final boss battle with Opposite Armor, which eventually seals the keyhole to this world. It is a lengthy process but after your 2nd visit to Traverse Town you can get back onto the roof anytime.