Apple invested in Maps so they have control over their destiny of one of the most popular use-cases people use their Smart Phones for as Google was with holding key features like turn-by-turn directions which would've given Android an edge. Apple always wants to be seen as the best, they love to say they offer the best Smart Phone with the best hardware, best OS, Apps, etc. Having a sub-par experience on a core feature would've hurt both their brand and sales. Although it required a significant investment and Apple Maps still isn't as good as Google Maps, end-users still end up with a first-class experience in iOS with their choice of either.
This isn't the same as Search, Google wants to provide the best Search service for iOS as possible and is now paying Apple billions for privilege of being the default. Attempting to develop an ad-free Search alternative would dilute their focus, cost them a fortune and their Customers would be worse off for it.
It's funny that you talk about Apple developing maps because Google was withholding features like turn-by-turn direction, and Apple wanted to give a better user experience.
In the country where I live (Brazil), Apple Maps does not have turn-by-turn direction available, while Google Maps has.
This isn't the same as Search, Google wants to provide the best Search service for iOS as possible and is now paying Apple billions for privilege of being the default. Attempting to develop an ad-free Search alternative would dilute their focus, cost them a fortune and their Customers would be worse off for it.