Code sharing and alliances are two different animals.
Code Sharing is when airline A blocks seats on airline B's route from city XYZ to city DEF. Then sells those seats with airline A's flight number. Airline A may only contract for one code share route with airline B or it may contract for 50 routes.
Airlines can code share with whomever they wish, irregardless of alliances. And they choose the routes they feel match their marketing goals and customer's needs.
Alliances revolve more around joint marketing of all members, plus convenice of connecting travelers with fellow alliance members. And while alliance members frequently code share with each other, the majority of flights are exclusive to the operating carrier.