I think that was Lap 5. The pass on Lap 4 was clean. Technically, on lap 5 Pecco did get through after making contact. It looked like Marc's ride height might not have engaged? I suppose race direction could have ordered him to give the position back to Marc.
While the contact between Marquez and Mir bears resemblance to Bagnaia and Marquez, the circumstances were a bit different. Marc was charging back through the field after crashing out the lead and he hit a hapless Repsol Honda rider who was in position to score a point. Considering the difference in pace, Marquez had plenty of passing opportunities, and it was Ducati on Honda contact.
Bagnaia and Marc were battling for the race lead, with similar pace, few overtaking opportunities and it was Ducati on Ducati.
I suppose riders shouldn't care what brand of motorcycle they are overtaking, nor should they avoid overtaking opportunities because they aren't at the front of the field; however, riders probably should be aware of the difference in pace, and make calculated overtakes. I think this is ultimately why Marquez was penalized, and it does make the collisions distinct, even though they looked quite similar to the eye.