If we connect the inverted output of a D flip-flop to the D input of itself, it toggles itself on every rising edge of the clock.
It toggles itself once (from 1 to 0 or from 0 to 1) in one clock cycle because there is 1 rising edge in a clock cycle. And it takes two toggles to make a new cycle, so the frequency is divided by two.
We can use this mechanism to divide frequency two half of the input frequency.