The nasty smell of a trashcan is most likely caused by bacteria and fungi feeding on the organic matter in the trash.
It will be most noticeable if the bin is in a warm and damp place. Bacteria love it when it’s warm and damp and multiple quickly.
The smell will not always be exactly the same, but it will be more characteristic of the different organisms than of the type of food they consume.
The smell you get from penicillin mould growing on an orange is just the same as that from penicillin mould grown in a laboratory culture. It is pungent, characteristic and very common.
Analysis of household trash have detected very pathogenic bacteria, including Pasteurella pestis, the bacterium responsible for causing bubonic plague. So don’t sniff too hard.
While taking out the trash we realised that trashcans do not smell the same.
A bag containing foodstuffs will inevitably be ripped open by local cats unless protected by a trashcan, but a bag without food is not. It would seem that, although the bags smell similar to humans, they are noticeably different to cats.
As for why they smell similar, that would be because they invariably contain similar objects.
However, garden refuse, or compost, smells nothing like kitchen trash, which in turn smells nothing like bathroom trash.