It is certainly true that military aircraft often operate in harsher conditions than commercial airliners, creating more wear and tear. But they could still be made more reliable. It comes down to how much the operator is willing to pay for a higher reliability, in terms of up front cost and performance.
Commercial airlines are running a business. They pay a lot for their aircraft, and every minute that the airliner isn't moving passengers from A to B is lost revenue. This causes inconvenience for the passengers and expense for the airline. Passengers tend to choose the airline that is cheaper and less likely to leave them delayed. And every dollar spent on maintenance comes out of profit. Similarly, manufacturers are competing to provide more reliable aircraft. They spend a lot of time ensuring their designs will be reliable, and improving designs based on service experience.
The military is in a different situation. Passengers or cargo is not at much risk of choosing a different carrier based on cost or reliability. And for willing to allow lower reliability, the military can trade it for lower upfront costs and higher performance. This means they can carry large cargo, make short takeoffs, climb quickly, operate unpressurized, make steep approaches, land harder on rougher ground, and stop quickly.
Age is another factor. Airlines in the US have average fleet ages of around 10 years (with some outliers on both sides). The active duty fleet of C-130 aircraft has an average age of 25 years. While military airlifters may fly fewer hours, age still factors into maintenance. Components break down over time. Newer planes will have the latest design updates and be less likely to develop issues.