As the president cancels projects in Democratic-run states, he is cutting money that benefits his own party’s lawmakers in some of the most competitive House districts.