WotC/TSR released the Dragon Magazine Archive in 1999, a 5-CD-ROM set collecting scanned PDFs of issues 1-250 of The Dragon/Dragon Magazine and issues 1-7 of The Strategic Review. These are cover to cover scans and include all the ads and everything. It is a great resource and one of my prized collectors items. You can find it on eBay sometimes.
It got WotC into a legal pickle, as they had not gotten permission from artists of their various comic strips like "What's New with Phil & Dixie" and "Knights of the Dinner Table." The KODT strip was produced by the folks at Kenzer. WotC worked out a deal with them to let them publish Kingdoms of Kalamar books under the D&D 3rd edition trade dress, and I think it also gave them the right to use AD&D 1st edition and 2nd edition as the basis for Kenzer's Hackmaster game.
There has never been a similar compilation of Dungeon Magazine, but there have been some legal PDFs out there. In the D&D 3.x era, Paizo produced and sold PDFs of many (but not all) of the issues of Dragon and Dungeon that they produced. Note the Paizo PDFs omit the ads, as well as some fiction and comic strips.
WotC produced PDFs for both titles for D&D 4e. I think some of the 4e PDFs were free on Wizards' website for a while. They also compiled one Annual of each title, and they are still available to buy on DM's Guild.
Lastly, there was a CD-ROM included with Dungeon 87 (July/August 2001) and Dragon 284 (June 2001) that included a PDF of Dungeon Magazine issue 1, along with two bonus adventures and some random generators.