Let me start this by saying that the title is a bit of a misnomer. Dogs cannot fly, no matter how fast of a running start they can get. While a hyper dog may be able to leap over several people, an ottoman, and half a couch with a single bound, they have no way to force air down such that they stay aloft. In the words of Tom Hanks, "It's not flying, it's falling with style."
Having said that, dogs actually can do a ton of cool things. Namely, standing on their two rear legs. The canine body is most certainly not designed for them to put their full weight on two legs, yet they are quite clearly capable of such a feat, as many internet videos can testify to. As such, how is this possible? While their center of mass isn't usually directly above their point of contact with the ground, meaning gravity would pull them down, dogs get around this with one simple trick: jumping. Almost every video where dogs are on their hind legs has them jumping on them to stand up. What does this do? Quite simply, with the way that they jump, they cause a torque on their bodies which cancels out the effect of gravity, allowing them to stay up in such an unnatural manner.