Can someone who knows my IMEI number compromise my mobile and access my social media accounts when I am connected to their Wi-Fi?
WiFi devices do not broadcast IMEI numbers. IMEI is used in cellular authentication. So no, they cannot "compromise your mobile" in any phone-related way.
However, if they are the owner/operator of the WiFi router (or anyone on the network if the router is not secure), they can read all data sent to and from your phone. Whether or not this data is actually readable is application-specific. Most popular social media apps will be using TLS or other encryption.