The Beaufighter was built with Merlins when Hercules production didn't keep up, and it was in high demand as the Beau was so versatile. The trial with Griffons was a logical next step.
Note that the Beaufighter was not in competition with the Mosquito, as although they both served in the same roles, it was a quantity vs. quality situation. Note that the Beaufighter had a longer range, especially helpful in shipping interdiction in so many theaters.