This trade is win/win because it leverages the different circumstances of both teams.
For the Capitals, this is more like signing Dubois to a 3 year 3.25M AAV contract. That is because their window to compete is closing. Ovechkin will only play a few more years. They don't have a deep prospect pool or players in the pipeline to keep things going after their core declines or retires. They will have to embark on a 5+ year rebuild. So if Dubois stinks for them, it will be irrelevant that he is signed long term at 8.5M.
Kuemper was a sunk cost at 5.25M for the next 3 years. So they effectively spent 3.25M to add Dubois to the final few seasons that they will have Ovechkin for. That's a worthy gamble to take. They were one of the few teams in the league who was in a position not to worry about the term of the Dubois contract.
The Kings on the flipside have a deep prospect pool and many good young players. They are just scratching the surface of what they can do. The term of the Dubois contract was going to be an albatross for them. Getting out of most of the contract is a huge positive.
There aren't many teams who could make this trade and not worry about the back half of the contract, but Washington was one of them.