Yes, the original robot was part of the ship; Dr. Smith sabotaged it to try to destroy the ship (but in so doing, accidentally trapped himself on the ship).
In the Episode, "The Mechanical Men", however, it is implied that the Robot may have been built using alien technology (the same technology used for the Mechanical Men) which could also explain some of the unusual abilities B-9 shows throughout the series (although you could handwave most of that by saying "advanced technology", the coincidence of the Mechanical Man remained unresolved, despite The Robot saying it knew why the robots looked like him.)