I remember playing this on an arcade machine in the late 80s. You started as a ship but by collecting power ups you slowly began adding robot parts until finally you were piloting a full size robot. That's all I can remember.
I'm pretty sure you're talking about Side Arms
It's not vertical or horizontal but rather depending on the level
You have a flying robotlike ship, pick power ups and after a while the ship (ships if you're playing a 2 player game) becomes a super-powered flying Robot that looks completely different from the not superpowered robot.
The special "feature" of this game is that when playing a 2-player game, both players combine into that super robot ship.
In addition to the standard power-ups, there are two special combination power-ups shaped like the Greek letters α and β that will combine the player's Mobilsuit with an ally. This allows the player to do an eight-directional attack at the same time as their regular attack. When two players are playing this power-up will combine both players' suits instead. One player will move the combined suit and perform the regular attack, while the other will provide the eight-directional attack. If the combined suit gets shot, it will revert both suits into their regular separate states.
Sinistar is a pretty good match with parts of your description: an arcade game with a vertical screen; the player pilots a spaceship collecting crystals (power ups); meanwhile a large robot is assembled piece by piece.
It isn't as good a match with your description in other ways: the robot is the player's enemy rather than their ship, and the player uses the crystals as bombs to destroy the finished robot in order to advance to the next level of the game.
Dangar Ufo Robo is about collecting multiple ships that, in the end, form a robot. It's vertical scrolling.