Why are both ATC and TCAS tasked to prevent collisions although TCAS takes precedence anyway?
While ATC's primary goal is to prevent collisions, it is also responsible for the efficient movement of aircraft through the airspace. That requires a strategic approach to managing air traffic to get aircraft from point A to point B safely and in a timely manner. The primary tool ATC uses is the flight clearance.  

If air crews follow their clearances accurately and VFR traffic maitains adequate visual separation, there won't be any problems with separation being met.

TCAS can't issue a flight clearance. It doesn't know anything more than the traffic it can track via Mode C or Mode S interrogations. It's a tactical system that provides a backup when ATC or the crew makes a mistake and separation is lost. In this case, the TCAS is the automatic backup to resolve the loss of separation and avoid the collision.  

The reason a TCAS RA must be followed, taking precedence over ATC, is that when there is a loss of separation immediate action must be taken.