Commercial aircraft windows (for the passengers) are cylindrical to match the cylindrical body of the plane. This is both stronger -- matching shape -- and more or less maintains a smooth, even drag surface. Their boundaries are near-rectangular just to match internal view angles from the seats.
OTOH, the cockpit windows are close to planar so as to minimize any view distortions that could make navigation difficult.
As to submarines -- there aren't any on military (in general) subs; research subs designed for deep investigations are as close to spherical as possible, and the glass is shaped that way as well. This is because strength is the main constraint, and as you probably know a sphere is the strongest configuration for pressure resistance.
Portholes on surface ships may be round for various historical reasons, but since they are usually above the water surface, they can be manufactured planar, saving cost and still meeting any strength needs.