Can Mercury hit Earth or Mars in the next 5 billion years?
Yes, after a close encounter with other planets, almost anything can happen, including a split of Mercury into smaller bodies by tidal forces, or capturing as one or more moons of one or more planets, or a sequence of captures by, and escapes from planets, conversion to a ring of all or some of the fragments, collisions with other moons, fragments falling into the Sun, others ejected from the solar system.