You didn’t do anything wrong.
He has mental health issues that have not been sufficiently treated.
The problem was not your fault.
His blaming you was a way to defend himself from facing his mental health issues.
The fact that he can flirt with others is irrelevant. He may look mentally healthy to them, but you have seen the truth.