Most teams are one player away from being a better team than they were the previous year. There are so few true difference makers, that the vast majority of GMs are desperately searching for that one guy that could potentially be that guy. Then if that guy comes in and has that career year, you might have a decent team.
The Caps know they're not going anywhere, but they also know they're not going to trade Ovechkin. So they, like the Kings, are throwing whatever at the wall, hoping something clicks. All they had to give up for the potential of Dubois, after probably his worst overall season, was a 34 year old/$5m goalie who had become their backup guy.
Sure, they might end up simply stuck with Dubois's contract, in one way or another, but they don't care about the long term. That's ok. It's not like the Caps are in danger of going out of business. They're not going to ruin their own retirement years. The franchise will be there. There's a thousand years to rebuild. You get one Ovechkin in a lifetime, if you're lucky. If they're giving him a 5yr/$9.5m cap hit contract at 36, that's explicitly saying they're not rebuilding soon. No thought of doing so.
It's not about being fooled. If, for whatever reason, something clicks for Dubois, the attributes and potential would make him, not a true difference maker(because you rarely have to wait for those types), but he's got the talent to make your team better. Which is all the Caps want, because they're not rebuilding.
Even if they bought him out after next season, his worst dead cap hits would be in the most immediate post-Ovechkin years, when the Caps will very likely be completely rebuilding. By the time they're good again, the dead cap is $2m, with the total cap probably higher outside of global catastrophe.
There aren't enough good players for every GM to always be "smart" all the time. If you haven't made a "stupid" move as a GM, just wait, because it's coming. It's part of the job, because you can't trust most players. McDavid, you know he's going to be great. Crosby, you know he's going to be great. 96% of the league though, you're guessing and hoping.