I interpreted this as the minimum possible races that could let you determine the fastest 3, but the solution given is the MAXIMUM number of races that is necessary.

The minimum happens happens when your first race has the top 3 horses.

There are then 20 horses remaining.

Race the 3rd best horse from your first race against the remaining 20 horses 4 at a time, which will take 5 races. Since he is the 3rd fastest horse, he will come in first in every race.

The total number of races is then 6.