Butter spoils less quickly than milk because of the amount of free water or available water in the food.
The microbes involved in spoilage require water to live and multiply.
Milk has a huge amount of available water, 93 or 94 percent, and butter has much less, so bacteria, yeast and molds are less able to grow in butter.
Milk lasts a matter of days, butter a matter of weeks.
Dry cheeses like Romano last even longer than butter because the cheese-making process is in large part the removal of water from milk.
Some milk is ultra-pasteurized for a longer shelf life, meaning that it is treated at an ultra-high temperature to kill off the bacteria that lead to spoilage.