This question comes from an assumption that Chinese government acts on its own free will, "not needing anyone's permission".
In fact, China is (and was, one year ago, and will be, 27 years after today) bound by its Constitutional principle colloquially known as "One country, two systems" introduced by Deng Xiaoping.
This principle is based on the internationally-acknowledged agreement signed as part of The transfer of sovereignty over Hong Kong back in 1997 and is valid till 2047.
The newly introduced National Security Law contradicts provisions of this constitutional principle:
China’s decision to impose the new national security law on Hong Kong lies in direct conflict with its international obligations under the principles of the legally-binding, UN-registered Sino-British Joint Declaration. The proposed law would undermine the One Country, Two Systems framework.
from UK Foreign Secretary Dominic Raab, Australian Foreign Minister
Marise Payne, Canadian Foreign Minister François-Philippe Champagne,
and US Secretary of State Michael Pompeo.
It is not publicly known why exactly China chose to obey its Constitutional principle before and broke it only this time, so the rest of the question will probably remain unanswered unless some official statement is released.