It looks like you’re mistake is in what a flat universe really means.
While the universe is generally believed to be flat as a large scale structure (meaning, flat in the same way a turbulent ocean looks flat if you zoom out enough) this does not suggest at all that that it behaves in a Euclidean geometric way. Spacetime by its definition is non-Euclidean; even a special relativistic treatment of spacetime shows that pretty quickly.
One indication of this early on in relativistic studies is that while two lines in, let’s say, a Minkowski-spacetime diagram look to be the same length, they are by no means the same length. This is seen in the Minkowski spacetime metric:
(The signs here may flip depending on who you ask)
As you can see, this completely negates the Euclidean way of determining lengths that would dictate that all of the signs be positive.