I have some friends who are Sunni and we used to hang out sometimes so when their prayer times come, they stop the car near a masjid and get inside to pray their namaz like maghrib prayer. So I also pray in their masjid according to their maghrib time. Is it ok if i pray maghrib namaz with their maghrib time?

Our scholars say it is precaution to wait until the redness in the East has disappeared. That is about 15 minutes after sunset. If you see that it has disappeared then you can pray at that time.