Cost of Borrowing for Banks:
The federal funds rate is the rate at which banks lend to one another overnight. When the Fed changes this rate, it changes how much it costs banks to borrow money.
Banks then pass these higher or lower borrowing costs on to their customers, influencing the rates for various loans, including mortgages.
While not a direct link, the Fed's actions influence the yields on Treasury bonds, particularly the 10-year Treasury yield, which serves as a primary benchmark for 30-year fixed-rate mortgages.
The Fed meets 8 times a year and decides whether to change rates or keep them the same at these meetings, so you might think that mortgage rates would change only every 6 weeks or so when these meetings occur, but in reality during the intervals, lenders adjust their rates based on what they predict the Fed will do a their next meeting among other factors.
Reading the Fed Tea Leaves
So if for instance there's a strong jobs report, or inflation data is released that's higher than expected, these will increase the chance the Fed will raise rates (or not change them if they were expected to be lowered), and mortgage rates will rise accordingly.
Consequently, when the Fed actually does lower rates, it often has no effect on mortgages, as the move has already been "baked in" to rates.