On common fixed points of compatible mappings in metric and Banach spaces