Some switches provide flexibility in how you can mount their ears so the switch can stick out more in order to fit rack constraints.
A more pricey switch like the Arista DCX-7060CX-32s has a depth of only 16". A lot of Aristas are shallow depth. Mellanox switches could in theory be as shallow but it looks like the depth is dictated by their PSUs.