Dortmund doesn't really get lucky when they buy good and talented young players and sell them for a lot more than they bought them. It is a system as you noted and that is something Dortmund mastered over the years and is now the club I guess with the best transfer history maybe? I
Bayern Munich remained the giant of bundesliga because they focus on the title more than any other club. Borrusia Dortmund are known for the potential important players they have in the club; the shocking part is that the club continues to sell these valuable players to elite clubs; there are significant players that have been sold out by these clubs, players like Robert Lewandowski, Jadon Sancho, Erling Haaland, and now Jude Bellingham has joined the race. The club isn't concerned with winning the Bundesliga; all they want is to continue making huge profits from the transfer market, and with their predicted budgets, they're doing just well.
They really have no choice but to sell them. What you are saying is only part of the whole story. Haaland would have never been in Dortmund when they didn't grant him the clause that he can leave the club for €60 or €70 million. In Haaland's case there was nothing they could do and they tried to raise his salary but they had no chance to compete with Manchester City. Real Madrid failed. Bellingham again, Dortmund tried to raise the salary but there was no stopping him from leaving the club and when the offer is so high Dortmund is not in the position to say no to it. Lewandowski was never sold. The truth is that Dortmund stayed tough and didn't even let them go knowing that a year later his contract would expire. Dortmund didn't get a penny from Bayern for Lewandowski but they could have made a lot from a transfer just one year earlier. They can't be blamed for their club policy. Players who grow up in their club prefer to leave as soon as the top clubs mention their names publicly for the first time. The choice is then to either let the contract expire and get zero money from a transfer or to sell at an expensive price.