When building items at a shipyard (which includes fleet AND defense items), the time spent is based on the ShipYard level. The higher the shipyard, the faster you can build.
Also, when upgrading a shipyard, you cannot build new fleets OR defenses. So keep this in mind when upgrading.
Furthermore, you cannot cancel anything being built by the ShipYard (which includes fleets and defenses). This is to prevent “saving exploits”, where you dump all your resources into ships to be created, then cancel them after the attacker is gone.
Robotic Factories do not affect your ship build times. Shipyards and Nanite Factories will decrease your build times.
Black Knight X is correct (see comment below). Robotic Factories do not affect the speed in which your ships are produced.