Did you learn maths ? Do you know how percentages work ?
If you have 40% out of 10, it means practicly that oyu can get 10 rares or none, its all about chances, yes they are bigger than 20% for legendary, but you were "lucky" and got triggered 4 times legendary item, so that 20% worked, when 20% for legendary works, you cant get rare any more.