They are in the f-block, as they have f-subshells. This is due to their electronic arrangement. Their electronic arrangement is such that: in lanthanides, 4f orbitals are filled before the 5d orbitals are filled, and in actinides, 5f orbitals are filled before 6d orbitals are filled. Two photos are attached to further explain this.