Why is there a difference between O2 and B2 sigma 2p molecular orbitals in diagrams?
This topic is really fun. You see in case of boron molecule $\sigma_{2s}$ and $\sigma_{2p_z}$ (being on the intermolecular axis) will have the same symmetry and hence the orbitals will overlap and result in the formation of 2 bonded $sp_z$ orbitals. So the $\sigma_{2p_z}$ orbital will obtain somewhat $s$ character and it will become unstable or in other words will be of higher energy. The $\sigma_{2s}$ MO will obtain somewhat $p$ character. So in a energy level MO diagram $\sigma_{2p}$ bonding orbital is placed above the $\pi_{ 2p}$ orbital.

However, in case of $\ce{O2}$, due to the higher nuclear charge of oxygen, the energy difference of $2s$ and $2p$ is large so there is no such kind of intermixing between the bonded MOs. Whereas in boron, the energy difference of $2s$ and $2p$ is less, facilitating intermixing.

You can find this topic in any higher level chem books. Hope you got my point; thank you.