The second part is a form that is no longer found directly in Hebrew. In (Standard) Arabic, the word for "where" is ’ayn(a). So presumably there was once a form similar to אין in Hebrew that meant "where". What we have surviving from it is only מאין. Also perhaps אנה and לאן (both meaning "to where") are also derived from it, having dropped the י. There is also a related form איה meaning "where" in Hebrew.