"I should not have done it" is used after you have done something and you want to say that it was a bad idea, or perhaps it was illegal and that (probably) you regret it.
I was angry with my mother and I threw a plate at her. I shouldn't have done it. I could have injured her very badly. It was lucky that I missed her.
I drank two pints of beer last night and then I drove my car. I shouldn't have done it. I know that it's wrong and dangerous to drink and drive.
I drank twelve pints of beer last night and got very drunk. I shouldn't have done it because I had to get up very early this morning to go to work and now I feel dreadful.
Student or Learner