Good question. In short I'd say that for a luxury hotel:
- An inability to guarantee quality.
- Difficulty forecasting and managing costs.
- Lack of reliable customer demand.
I used to audit a couple of international 5-star hotel chains and have visited a good number of hostels/mid-range hotels in various capacities, though I never remember someone being overly unhappy about the lack of cooking facilities. I only ever remember a few times when there was something like a toaster, microwave or a small grill perhaps to heat up that slightly stale bread just right. But breakfast is easy, low cost, easy to scale up, low wastage; most of the unused produce can be used the next day, and often it is included with the cost of the room, so easy to predict required staff/food etc.
If they were to provide cooking facilities what would a customer want? At a top-end hotel I'd expect them to supply everything I could possibly need for me to cook my meal. Think of every type of pan, spatula, muffin tin, condiments, fruits, vegetables, meats, oven fridge, freezer. You would also need staff, at least one person just to make sure the place doesn't burn down which adds an overhead (fixed) cost. Also one day everyone may want to make something and the next day nobody does. Imagine a stag (bachelor) party is making a load of steaks but a vegan family wants to make a birthday cake for their 7 year old daughter.
Hotels can look to make profit through many services, the rooms/accomodation generates profit through economies of scale and efficiency of processes. The restaurants (of luxury hotels in particular) normally have large margins on high quality food. Hoping to draw the more lazy hotel guests and outside diners. Often hotel restaurants can survive despite only being half full on the busiest night. They already have a kitchen for breakfast and room service so why not have a restaurant as well? They tend not to offer services with low profit margins though - hotels don't normally offer a taxi service, for example (apart from places such as the Burj Al Arab which you probably wouldn't describe as a 'taxi'), because it doesn't make them enough profit.
Certainly - as others have mentioned - supplying cooking facilities would eat into potential restaurant profit, but I'd say it's a secondary factor.
At a hostel the expectation of quality is lower and you would expect everyone there to make the majority of their meals there. Effectively making it lower cost per use of the cooking facilities, more predictable and also it's something people look for when searching for hostels.
Hotels in the middle range have to find a way to differentiate to make themselves appealing. Often it's value or they can often have things such as a bar or some other particular draw for guests.
Obviously luxury- and low-end accommodation do as well but it's generally fairly low on the list for people travelling who are already spending a lot of money on other things. Travel to the destination and accommodation will normally dwarf the cost of eating so travellers see it as an additional cost which is low and anticipated.
Apologies - bit of a ramble and I could go on but hopefully that gives the primary reasons.