The exact rules vary based on altitude, area, type of flight, etc, but the rule lost likely applicable in your case is that flights are on flight levels (FL) which are multiples of ten, either an odd multiple of ten (FL270, FL290, FL310…) if they have a heading between 0 and 179 degrees, or an even multiple of ten (FL260, FL280, FL300…) otherwise.
Flight levels are multiples of 100 feet.
So you could have one flight heading west or north-west like yours on FL260 (26000 feet) while another flight is heading east on FL250 (25000 feet). That’s a difference of 1000 feet, roughly 300m.
If both planes were heading in (roughly) the same direction, it would be double.
Given the size of aircraft, one flying 300m from yours may seem extremely close, but there’s no risk there, this is just regular operations.
Another possibility if the aircraft was A LOT closer (but probably a lot smaller) is that there was some kind of situation (e.g. radio malfunction) and a military jet was sent to check if everything was alright. But that’s quite the rare occurrence, and since you apparently got to your destination without trouble, nothing bad happened.