Some are born good leaders, some grow to become good leaders, and most have no business as leaders. You can be taught to be a better leader, but you can't be taught to be a leader if you lack the aptitude. I've seen that firsthand from a couple managers in my life and I bet anyone who has a long career in the corporate or retail world has seen it far starker.
It takes a certain balance of confidence, decisiveness, wisdom, and people skills to be a good leader. Not everyone has the same balance. I say wisdom rather than intelligence because, although no good leader is dumb, effective leadership is about maximizing the use of intelligence around them. Highly intelligent people are better utilized as trusted advisors to leaders.
I will boldly say that, relative to their wars, the biggest difference between Eisenhower and Bragg is not strategic or logistical, but that Eisenhower was a master of handling subordinates and superiors while Bragg was inept at the same task.
McClellan and Johnston were both good with their subordinates, but both had terrible relationships with their commander in chief.
Lee knew how to tactfully get rid of subordinates he didn't like.
And yes, there's luck too. It's the most important and elusive superpower in the world.