Megapixels only indicates number of pixels an image is made up of. It does not mean that more the megapixel more better the photo will be. Thereby we can never compare two mobile phones or two cameras having same megapixels and expect the same results from both of them.
Quality of camera depends on various factors:-
1) Lens quality i.e., it should have sharpness, quality of bokeh etc.....
2) Image stabilization through hardware,
3) Software like stabilization,
5) Sensor size,
6) Sensor quality i.e., it should produce less noise and should be high in dynamic range,
7) Pixel size of censor,
8) Camera firmware,
9) Color reproduction quality of a camera etc.....
Difference in so many factors will affect quality of cameras of two different mobiles of same specification.