In france, if you are in a position to help someone who is in danger, and you decided not to even though there is no immediate danger for yourself, you can be prosecuted. This is defined in article 223-6 du code pénal and is often referred as "non-assistance à personne en danger"; also called "duty to rescue" in English.
Original text and DeepL translation below:
Quiconque pouvant empêcher par son action immédiate, sans risque pour
lui ou pour les tiers, soit un crime, soit un délit contre l'intégrité
corporelle de la personne s'abstient volontairement de le faire est
puni de cinq ans d'emprisonnement et de 75 000 euros d'amende.
Sera puni des mêmes peines quiconque s'abstient volontairement de
porter à une personne en péril l'assistance que, sans risque pour lui
ou pour les tiers, il pouvait lui prêter soit par son action
personnelle, soit en provoquant un secours.
Les peines sont portées à sept ans d'emprisonnement et 100 000 euros
d'amende lorsque le crime ou le délit contre l'intégrité corporelle de
la personne mentionnée au premier alinéa est commis sur un mineur de
quinze ans ou lorsque la personne en péril mentionnée au deuxième
alinéa est un mineur de quinze ans.
DeepL translation:
Any person who can prevent by his immediate action, without risk to
himself or to third parties, either a crime or an offence against the
physical integrity of the person, voluntarily refrains from doing so
is punished by five years' imprisonment and a fine of 75,000 euros.
Will be punished with the same penalties whoever voluntarily refrains
from giving to a person in danger the assistance that, without risk
for him or for the thirds, he could give him either by his personal
action, or by provoking a help.
The penalties are increased to seven years' imprisonment and a fine of
100,000 euros when the crime or offence against the physical integrity
of the person mentioned in the first paragraph is committed against a
minor of fifteen years of age or when the person in danger mentioned
in the second paragraph is a minor of fifteen years of age.
Although it does not directly answer the question as to whether or not it is legal to use force against a person who is trying to stop you from rescuing another person, it does say that you are expected to do what you can to attempt to provide assistance.