The headline in The Washington Post in a story about the bill, "House Set to Spend $6.9B on Unwanted Military Equipment" is a little misleading. There are certainly earmarks for equipment that was not requested by the Defense Department in their budget. That does not mean the additional C-17 aircraft or other money added by Congress is not wanted by the different services.
The Army, Air Force, Navy and Marines send their budgets to the Office of Secretary of Defense (OSD) for review and mark up before it goes to Congress. This office as is proper makes adjustments to the individual budgets to meet the goals of the Administration. This is then in turn marked up by the Office of Management and Budget (OMB) to make sure it matches the overall plans of the total budget. Money can be moved between the services and even out of the DoD budget and elsewhere as required. Congress then has the right to add or subtract money themselves as they see fit. In totality the changes are of a small order in dollar value.
The article does point out that just because OSD and OMB remove things that is not necessarily saying the services don't want the hardware, services or equipment. The Air Force may accept the ending of C-17 production but in one-way-or-another they can let it be known to Congress that three more aircraft will be used and will provide a necessary capability. Since Federal employees are not allowed to lobby Congress directly an easy way is to have the contractor do it for them. Since it is often in the best interest of the companies to maintain these contracts they are certainly able and willing to do that.
All of the services maintain lists of things that they would buy if they had the money available. These lists of Unfunded Requirements (UFR) are ranked in priority at the service and then OSD level. Sometimes Congress will request these lists and use them to build money into the budget or when reprogramming or supplemental funding requests are done. It is easy to say that UFR's are just nice-to-have things but often the are items that the core funding will not buy. There is nothing in there that will make it impossible for the military to carry out their missions but they might make it more efficient or less stressing on existing capability to do so. The Air Force needs lift and more C-17's while expensive to build and operate provide capability and extend the life and availability of the fleet.
So just because it ends up as an earmark does not mean the equipment or service being bought is a bad thing. There are plenty of earmarks that are a pet project or based on campaign contributions but most of those are R&D projects or buys of small equipment not normally large aircraft from a hot production line that has been going on for several years.