How did Mars come to have a 24 hour 39 minute day? Mercury rotates three times for every two revolutions around the Sun, apparently due to a gravitational resonance with the Sun.Venus takes about 225 days to rotate, and rotates in the opposite direction of any of the inner planets. Maybe because its extreme nature makes it ornery.Earth rotates once every 24 hours, a condition caused by the tidal interaction between Earth and its Moon. It's believed that the Earth was rotating about once every 5 hours before the theorized collision with a Mars sized coorbiting object referred to as Theia.Mars shows no signs of a similar collision. Its two moons appear to be asteroids that were captured from the asteroid belt. So how did Mars come to have a day so close to the length of an Earth day?
"It's believed that the Earth was rotating about once every 5 hours
  before the theorized collision with a Mars sized coorbiting object
  referred to as Theia."


Almost. Theia did not have to be co-orbiting, just an intersecting orbit. We have no idea what the Earth's spin was before the collision, but it is theorized that the Earth rotation had a 5 hour period after the collision with Theia, at the time of the Moon's formation from the debris. 

The fact that Mars and Earth have such a similar period is a coincidence, perhaps you are asking why Mars is spinning so fast? Well actually Mars is not the odd man out, Mercury and Venus are. Most planets spin fast. exactly which spin orientation is somewhat arbitrarily determined by the vagaries of the ways the planetesimals collided to form them. The fact that Venus and Uranus have unusual spin orientations is just the way things turned out.

Both Mercury and Venus used to spin much faster. Mercury's spin was tidally slowed down by the Sun and Mercury's orbit was (and still is being) driven further away by the Sun (just like the Moon and Earth: Why is the Moon receding from the Earth due to tides? Is this typical for other moons?). Eventually Mercury was held in that 2:3 resonance. Which, by the way had a certain amount of luck involved (see: Mercury’s capture into the 3:2 spin-orbit resonance as a result of its chaotic dynamics ). Venus, we are not so sure of.

The tidal force from the sun is much much less for Venus than for Mercury, but much more than for Earth. However Venus has a dense hot massive atmosphere, which can be forced into both gravitational bi-modal (two peaks) tides and thermal uni-modal (one peak) tides. The bulge lags behind the tidal forcing peak, which creates a torque by the sun to slow it down. This is fiendishly complex (See: Long term evolution of the spin of Venus - I. Theory )



P.S. Actually Phobos, and probably Deimos, are thought to be constructed fairly recently (millions of years) from debris from a collision of Mars with a large asteroid. There is no way to capture a whole asteroid into orbits that close.