For B2(10e−), the MO configuration is (σ1s)2(σ⋆1s)2(σ2s)2(σ⋆2s)2(π2p1x≈π2p1y)
Due to the presence of unpaired electrons (2p1x=π2p1y)B2 shows paramagnetism.
For C2(12e−), the MO configuration is (σ1s)2(σ⋆1s)2(σ2s)2(σ⋆2s)2(π2p2x≈.π2p2y)
No unpaired electrons are there in C2(π2p2x=π2p2y), hence it shows diamagnetism.