There are very good universities focusing on computer science and software engineering in most countries.
This is the first step. Then one needs to find a company with a good engineering culture, apply the theory they learned and gather experience.
Ideally one should find a qualified engineer as mentor.
Self-study and being aware of developments in the profession are the last piece of the puzzle.
Yes, some people won't be able to do some of these things and as a result they won't be good software engineers. They could still be successful programers, the two aren't necessarily related.