Transaction number is not correlated with mining energy expenditure.
Mining is used to secure the ledger in a way that the same amount of energy is needed to alter it.
The block hash begins with a number of zeros.
Try for yourself how many tries it takes to find a string that hashes to a hash beginning with 3 zeros.
Bitcoin block hashes begin with 13 or 14 zeros IIRC. This means that you need to try trillions of combinations again if you want to alter a block. And then you must keep finding other hashes with enough zeros fast enough to outcompete the whole network.
But the cost of hashing is the same, with 1, 10 or 1000 transactions in a block. And the block time is on average fixed at 10 minutes.
You don't hash transactions directly, you hash a block header that keeps only the merkle root hash of the transactions. The merkle root is fixed size.