Federal government spending affects local economies because there are types of federal spending that result in money being spent in various localities. This can happen in a number of ways.
A good deal of federal spending comes in the form of government procurement. The government needs to buy goods and services and it buys them from local companies. For example, the military needs to procure tremendous amounts of everything from food to missiles. It pays companies in various localities to produce these things. This helps the local economy.
Government spending can also affect local economies if the government spends on things that attract people to a locality. For example, if there is a national park near to a town, government spending on that park allows the park to attract visitors. The visitors spend money in the local economy.
Government spending can also come in the form of directly paying people who live and work in a given town. For example, the federal government might give grants that pay for the salaries of certain teachers or other school workers. This government spending results in those people getting paid and then spending their money in the local economy.
In all of these ways and more, federal government spending can affect local economies.