In Deadpool, that is very much by design but for Shazam!, it is a bit more circumstantial as Zachary Levi’s character has only shown up in his solo film so far and Warner Bros’ DCEU still seems to be in kind of an ambiguous place as to whether or not it wants to be a full-fledged cinematic universe akin to the MCU, have some connectivity or just be entirely separated.
But for now, as Zachary Levi said, Shazam! is in the DC Universe but doesn’t have to strictly adhere to everything happening within it.