When an entity is standing above a shulker box that gets opened, it gets pushed upwards by the shulker box's lid for as long as the box is opened.
This does not occur when a rail is placed on top of the shulker box with a minecart riding the rail. If you open a shulker box, the minecart (and any entities riding it) will awkwardly bob up and down until they eventually clip through the lid's collision, and return to their original position.
Another minor detail is that the minecart's hitbox will move, but since it's in the same block as the rail, its model will stay snapped to the rail, creating a desync between the model and the hitbox.
Example gif shows a minecart with a rail underneath on the left and a minecart without anything on the right as a control, to display intended behavior.
A) The minecart and any entities inside it prioritize staying on the rail instead of being pushed by the shulker box.
B) The minecart and entities inside it correctly adhere to the shulker box lid's collision and rise and fall like how they do without a rail underneath. Also, the minecart's model follows the hitbox correctly when doing so, instead of being displaced from one another.