They are adopting HTML5 for video because video is becoming more and more essential part of the web and an open standard for it makes the browsers of both companies independent of any particular plugin. No sane company wants to be dependent on others.
As for them choosing h.264 - that's simple too - h.264 is open standard (as in, no single company or other entity has the ability to change it at some random point in some random way) and is widely used already (i.e. there is a lot of software and hardware support). On top of that the patent situation with h.264 is much clearer and safer (e.g. given h.264's huge use, the longer no submarine patents surface, the higher the likelihood that there aren't any).
edit: fixed typos