Any law or regulation exists because of a variety of interests trying to make it happen for their own reasons.
Certainly, the initial reasoning for medallion systems was quality of service and safety. As time goes by and taxi lobbyists become more powerful, they find ways to subvert this into limiting competition. Maybe some city councillor traded his vote on this issue to get a park built in his district, or for support in a primary.
It's not like some Big Government Socialist sat down, twirled his moustache, and said "I think today I will limit competition in the taxicab industry".