Because that is the number of transactions that the block builder included in their block.
The person that builds the block (or more specifically, the software that is being used by that person).
When a solo-miner or mining pool builds the block to be mined, they get to choose which valid transactions (if any) they want to include. As long as they only choose valid transactions, and the sum of weights of all the transactions that they choose doesn't exceed the block weight limit, the block is valid.
To add to what DannyHamilton said:
Miners have the incentive to publish a newly found block as quickly as possible, because if someone else beats them to the punch their block may be orphaned and they miss out on the block reward.
So if for some reason their mining software had only 8 transactions prepared for inclusion at the time the new block was found, it gets immediately published regardless of how much block space would have been left. These sort of blocks often happen when a new block has been found exceptionally fast (for example within a 1 minute interval instead of the expected 10 minute interval), meaning that the mining software had yet to catch up with validating the previous block and checking which transactions are still left in the mempool. Keep in mind that accidentally including an already confirmed transaction would invalidate the block you just found, meaning a loss of block reward, which means that the safest bet for a miner is to only include transactions of which they know that they wouldn't lead to an invalid block -- which in the most extreme form leads to the mining of an empty block, as in this case they only include a single transaction that is absolutely guaranteed to be valid -- the coinbase transaction, ie. their block reward.
In general though, miners are incentivized to include as many transactions as possible, as to gather transaction fees. So if a miner finds a new block while the transactions to be included have already been prepared -- which, as mentioned above, can take some time -- they would be stupid to simply leave them out.