The man had been convicted of arson by a Munich court in 2009 and sentenced to five years and ten months in jail, the prosecutors revealed.
Since then he had been wearing an electronic ankle monitor, which was intended to prevent him leaving the refugee camp in Arnschwang, near the Czech border, where the crime took place.
Munich tried to have the man deported in 2014, but he fought a successful legal case against the expulsion, claiming that he had converted to Christianity and that his life would be in danger in Afghanistan as a result.
Prosecutors did not go into further details on why the crime occurred.
On Saturday evening, the 41-year-old took the young boy hostage, before fatally injuring him with a knife. In the subsequent police operation, officers shot the man and he died of his wounds.
The young child's mother was also seriously injured in the confrontation with the man. She was treated in hospital for serious stab wounds, but they are not considered to be life-threatening.
The family, which also includes a six-year-old boy, were asylum seekers from Russia.