I have a feeling this is missing something, but I want to give this a shot. This is my first answer on PSE so feel free to let me know if there is anything wrong with my formatting or answer.
My job is to stand by the doctrines of good
Magnets are used in a compass. A moral compass is meant to point in the direction of what is good.
And yet they call me a racist, they actually should
Could this be a reference to the polarity of a magnet, that there is a positive and negative pole? Magnets can both attract and repel.
So, How many elements are there in the set ?
A magnet attracts iron, one of the elements in the periodic table.
You could even link me to a circle, I bet.
Another reference to a compass, perhaps?
Need to swing the ball ? Well, call me, won't you ?
This one is tough, I assume it has something to do with the magnet pulling the ball in a given direction? I'm stretching here. I also don't know much about cricket, so the hint in the question about a cricketer might be related to this clue, but I don't quite know the reference.
And then you'd realize that I'm a superhero too.
Magneto is a superhero in the X-Men series.
I always like joining the opposites, as I may...
This part seems self explanatory, opposite poles of a magnet are attracted to each other.
Well, cause "Opposites attract" is what they say.
This explanation is similar to the last line.