The elements whose electron configurations end with f electrons are in the Lanthanide and Actinide series: those long series at the bottom of the Periodic Table (see image).
The atoms are adding electrons into f orbitals, but the f electrons are not always the last electrons in the electron configuration.
For example, the electron configuration of Eu is [Xe]6s²4f⁷, but that of Gd
is [Xe] 6s²4f⁷5d.
I have blocked off in red all the exceptions like Gd.