I guess that a sufficiently brilliant science fiction writer could probably invent imaginary physics to explain why starships have to be aligned when they met.
But I prefer to just think that starfleet has a convention of always politely tilting their ships to align with the orientation of ships that they meet in space.
Or maybe the "real" starships in Star Trek don't resemble the physical or GGI models made by present day special effects artists, and don't "really" have their orientations aligned when they meet, if they even have tops and bottoms at all.
Part One of Six:
The design of visual media space opera space ships.
I have always thought that the design of spaceships in many movie and television space operas is illogical.
They are designed like sea ships or airplanes on Earth. They are usually longer than wide and usually wider than tall. Their long axis is perpendicular to the direction of their internal generated gravity fields, so that the direction of up and down in the spaceships is perpendicular to the long axis and thus to the direction in which they travel.
So when the spaceships accelerate or decelerate the g forces caused by that will be along the long axis of the spaceships and thus at right angles to the artificial generated internal gravity of the spaceships. So the artificial generated gravity in the spaceships will not only have to compensate for the strength of the acceleration and deceleration g forces to keep the crews alive, but also compensate for the direction of them as well.
I think that starships should be designed like tall, narrow, skyscrapers. sort of like Number 432 Park Avenue in New York City:
Only with a circular cross section instead of a square cross section.
If a space opera spaceship was designed like a tall, narrow, cylindrical skyscraper with many narrow circular decks one above the other, the direction of the generated gravity fields within the ship, its up and down, would parallel to the direction of the ships long axis and the direction it would travel in. Thus when the ship accelerated and decelerated the g forces produced would be in the same axis as the ship's artificial generated gravity, and the gravity generators could simply increase or decrease their output to compensate, instead of also having to adjust the direction of the g forces.
Such a system would be much easier to operate and have a much smaller probability of catastrophic failure.
If two such space craft detected each other with their sensors and wanted to meet, they would turn toward each other and approach. Their "bows" would also be their top surfaces, and their "sterns" would also be their bottom surfaces. So when they met with their bows facing each other and their sterns pointed away from each other, their top surfaces would be facing each other and the direction of "down" due to generated gravity in each ship would be facing away from the other spaceship.
And if the space ships were tall, narrow cylinders, designed to minimize the probability of running into gas, dust and rocks in interstellar space, with their bows facing each other, each would present a narrow circular target to the weapons on the other ship if a fight happened to start.
Star Trek and Star Wars and other movie and television space opera spaceships are usually designed like sea ships or airplanes on Earth. They are usually longer than wide and usually wider than tall. And they usually have visible portholes or windows marking the lines of their internal decks.
Thus when two visual media space opera ships meet and have their bows pointed at each other, it is usually easy for the viewers, and for the crews of each ship, to tell which direction the "up" and "down" of the other ship is facing. And in visual media space opera the "up" and "down" of the two ships are always aligned.
Part two of Six:
Visual media space opera spaceship crews might deliberately align the orientation of their ships with that of ships that they meet.
Of course it is always possible that when two space ships approach each other they both tilt themselves so that their directions of up and down become more and more aligned until they are the same.
Or maybe in Star Trek other cultures don't bother to do so but Federation Starfleet ships that the protagonists are in always always politely make the effort to align their axis of up and down with the orientation of the other ship.
Such deliberate actions to align the two axis of up and down when ships are approaching each other seems like the only possible reason for their axis of up and down to be aligned. I can not imagine any reason why all all visual media space opera spaceships would have the same alignment of their axis of up and down.
Part three of Six:
How to create a physical reason for the alignment of space ships in an idealized Milky Way galaxy.
On Earth, ships in the ocean float on the surface of the ocean, on the interface between water and air. And since those ships don't have artificial generated gravity and instead experience the natural gravity of Earth pulling toward the center of the Earth, their decks have to be perpendicular to the direction of Earth's gravity.
Submarines have much more freedom of vertical movement than surface ships. But because the dense water provides a lot of resistance to movement they don't move fast nor change course fast. Thus the g forces their movement generates are tiny compared to Earth's gravity, and if a submarine tilts at a large angle the crew will be unable to move around on the decks.
Now picture a very idealized model of our Milky Way galaxy with its hundreds of billions of stars.
Imagine that each and every single star orbits around the center of the galaxy in the galactic plane. Imagine that each and every star rotates with its equator in the galactic plane and its axis of rotation perpendicular to the galactic plane. Imagine that each and every planet of every star orbits that star in the equatorial plane of the star, and thus in the galactic plane.
Thus any interstellar journey would have to be in the galactic plane, since all the stars and planets were in the galactic plane.
Now imagine some imaginary force in the Milky Way galaxy, that forces all spaceships to travel with their axis of up and down in the same orientation relative to the galactic plane. Apparently the internal generated gravity fields of the ships interact with the mysterious imaginary force and turn the ships so they are oriented with respect to the galactic plane.
Imagine that the mysterious imaginary force aligns the axis of up and down within a ship so that up is always pointed away from the galactic plane and down is always pointed toward the galactic plane.
Imagine that spaceships always have to travel slightly "above" or slightly "below" the galactic plane. Thus there would be a 50 percent chance that when two starships met they would be aligned the same way and a 50 percent chance they would be aligned in opposite orientation.
And if you can imagine some imaginary science reason why all spaceships have to travel on the same side of the galactic plane, then there would be a one hundred percent chance that two spaceships that met would be aligned the same way.
Part Four of Six:
The Milky Way galaxy doesn't fit that idealized model.
But how realistic is this idealized galaxy?
If you look at the night sky, when and where it is dark enough for the stars to be visible, you will see stars in all directions. Stars close to the north, south, east, and west horizons. Stars halfway from the horizon to the zenith. Stars very close to the zenith. Stars scattered across an entire hemisphere.
Anyone who has ever seen a sky full of stars should realize that the stars are not all confined to a single mathematical plane as in that idealized Milky Way galaxy.
Our Milky Way galaxy has a spherical halo of thinly scattered stars and mysterious "dark matter" with a radius of at least 100,00 light years and diameter of at least 200,000 light years. Most of the stars in the galaxy are within the galactic disc, which has a radius of about 50,000 light years and a diameter of about 100,000 light years.
Although the "upper" and "lower" 'surfaces", to use the terms loosely, of the galactic disc are very vague as stars gradually thin out with increasing distance from the galactic plane, we can more or less accept the thickness suggested by Wikipedia:
The Milky Way is the second-largest galaxy in the Local Group, with its stellar disk approximately 100,000 ly (30 kpc) in diameter and, on average, approximately 1,000 ly (0.3 kpc) thick.4
In the region of space near the Sun, the stellar density is estimated to be 0.004 stars per cubic light year.
Since the Sun is near the galactic plane, we can imagine that a cylinder of space about 500 light years long perpendicular to the galactic plane would reach from the Sun to either of the "surfaces"" of the galactic disc.
If such a cylinder had a radius of 0.5 light year and a diameter of 1 light year it would have a volume of 392.7 cubic light years and contain about 1.5708 stars.
If such a cylinder had a radius of 1 light year and a diameter of 2 light years it would have a volume of 1,570.8 cubic light years and contain about 6.2832 stars.
If such a cylinder had a radius of 2 light years and a diameter of 4 light years it would have a volume of 6,283.19 cubic light years and contain about 25.13276 stars.
If such a cylinder had a radius of 4 light years and a diameter of 8 light years it would have a volume of 25,132.74 cubic light years and contain about 100.53096 stars.
So there are a number of stars that are almost exactly 90 degrees from the galactic plane as seen from Earth.
Here is a link to a chart of the visible stars as seen from Earth, with the chart arranged in astronomer's galactic coordinated system. The galactic plane is the equator in the charge. The stars at the poles of the chart are farthest from the galactic plane as seen from Earth.
One pole is in the constellation Como Berenices, with the constellations of Ursa Major, canes Venatici, Bootes, Virgo, and Leo around it. The other pole is in the constellation Sculptor, with the constellations Cetus, Pisces, Aquarius, Pisces Australis, Capricornus, Grus, Indus, Tucana, and Phoenix around it.
Stars in those constellations visited in various Star Trek movies and episodes include:
Cor Caroli https://memory-alpha.fandom.com/wiki/Cor_Caroli_V
Tau Ceti: https://memory-alpha.fandom.com/wiki/Tau_Ceti
Omicron (Mira) Ceti: https://memory-alpha.fandom.com/wiki/Omicron_Ceti
Epsilon Indi: https://memory-alpha.fandom.com/wiki/Epsilon_Indi_system
So spaceships in Star Trek are not limited to travelling along the galactic plane. and thus can not keep themselves oriented relative to the galactic plane.
Part Five of Six:
Coming up with even more complicated explanations for a more realistic galaxy.
So any Star Trek fan who wants a reason why starships have to be orient the same way when facing each other needs to come up with their own explanation.
They will have to imagine that starships travel along some sort of lines of force of some kind between stars, lines of force which will have to constantly move as stars change their relative positions slightly as they orbit around the center of the galaxy.
And if each star has a line of force connecting it to every single one of the other at least 100,000,000,000 stars in the galaxy that will be a lot of lines of force. Possibly each star will have lines of force connecting it to the nearest 1,000, or 100, or 10, stars instead, to keep the number of lines of force reasonably limited.
Possibly warp drive works much better when travelling along those lines of force, or doesn't work at all away from those lines of force. So starships have to travel along those lines of force.
In order to get the starships aligned with each other, perhaps each line of force is an invisible ribbon a few million miles wide and light years long. And if for some reasons starships can travel only on one side of the ribbon and have to keep their bottoms pointed at the ribbon, they would all be aligned the same way when they met.
Or maybe the line of force is an invisible cylinder, and the starships have to travel just outside (or just inside) the surface of the cylinder. If they have to keep their bottoms pointed at the surface of the cylinder they would all be aligned the same. And if the diameter of the cylinder was large enough compared to the average distance between ships in a fleet, they would all seem to moving along an infinitely wide plane.
Part Six of Six:
So a sufficiently brilliant science fiction writer could probably invent imaginary physics to explain why starships have to be aligned when they met.
But I prefer to just think that Starfleet has a convention of always politely tilting their ships to align with the orientation of ships that they meet in space.
Or maybe the "real" starships in Star Trek don't resemble their physical or GGI models, made by present day special effects artists, and don't "really" have their orientations aligned when they meet, if they even have tops and bottoms at all.