Answer: 7 races are needed. Divide the 25 horses into 5 groups of 5 and run one race per group. After those 5 races, you know the internal order of each group. Let's call the groups A, B, C, D, E, already ordered internally: $$
A_1>A_2>A_3>A_4>A_5,
$$ and the same for the other groups. Now you do a sixth race with the winners of each group. Suppose the result is: $$
A_1>B_1>C_1>D_1>E_1.
$$ So $A_1$ is the fastest horse of all. You can also rule out many candidates: - no horse from groups D and E can be among the top three;
- from group C, only $C_1$ can aspire to the top 3;
- from group B, only $B_1$ and $B_2$ can aspire;
- from group A, only $A_1$, $A_2$ and $A_3$ can aspire. Since $A_1$ is already first, there are five candidates for the second and third positions: $$
A_2,A_3,B_1,B_2,C_1.
$$ A seventh race between those five decides second and third. 6 races are not enough, because after comparing the winners there are still five horses compatible with occupying the second and third positions. Without facing them directly, there is not enough information to sort them. Therefore, the minimum is 7.