the past events in "the doctor" take place sometime before those in "hat trick."
It isn't explained in the show, because Seb Stan (Jefferson's actor) got busy with the MCU and other projects. But it was explained in a canon comic. Basically, Jefferson is well-to-do because he is a portal jumper, and goes places to get things from various realms which he can sell, etc. One time, he goes to Wonderland for a magical watch and gets trapped in a time loop by the March Hare (which is a person that hunts the Wonderland rabbits, who are sentient and so basically people; watch the spin off Once Upon A Time in Wonderland for more about them). Jefferson's wife (and Grace's mother), Pricilla, comes to save Jefferson, but gets killed in the process. Because of this, Jefferson gives up portal jumping, thus losing his source of income. This is also why he is so reluctant to help Regina in "Hat Trick".