Is it normal to only get erections while masturbating but not when in the real situation?

Normal? Depends. If you don't get erections with hetero or homosexual relationships, then you may need some help. This could be psychological. 90% of sex is between the ears. Your sensate focus is needed to get and maintain erections. I would suspect you are having some issues with intrusive thoughts, phobias, performance anxiety or other relational, behavioral or psychological issues. Get some help and diagn.
Yes. This is usually due to performance anxiety or psychological factors such as discord in the relationship. You need to figure out and discuss with your partner any unresolved issues that exist in your relationship.