Why are ATMega8 and 168 more costly than 328?

Looked at Digikey to get them as I needed a few to solder on board and saw that those with less memory costs more than one with more memory. Why?

Supply and demand.

We are discussing what is essentially a "commodity". And one that is a little long in the tooth.

The non-P versions seem to all cost more money. Probably due to lower volume and/or Atmel/Microchip trying to nudge people towards the newer versions.

If you compare 168p vs 328p, the 328p is more expensive.

A manufacturer once reminded me that cost and price are not necessarily related.

Nor are value and price. Economics is known as the dismal science.