The Hubble Space Telescope UV Legacy Survey of Galactic globular clusters - XI. The horizontal branch in NGC 6388 and NGC 6441