When I connect a contact to same membership type, the system displays a warning message that it is a duplicate membership for the same contact, but still allows to to perform the action. Then I get two active records for the contact with same membership. How can I avoid it in such way that the system will block the ability to create more that one active record for same membership type?
I suspect the OP needs to avoid the creation of double backend membership with the same type. Something which would look like -
This could be a bug(not sure) as this doesn't happen when registered through contribution pages. I don't think there is any setting in civi UI which would avoid this, but it is possible with a small extension(learn here) where you need to check for double membership type registering for a single contact id.
It sounds to me like a staff training issue rather than a software issue. The way you describe the problem, your staff are going to create a new membership, then when a big warning box pops up telling them that it already exists, they ignore it and carry on anyway.
If staff training doesn't solve the problem (e.g. you are using a revolving door of volunteers and there is no way to train them) then you probably shouldn't be giving them access to your CRM at all. Instead, you could set some Webforms to let them enter data for you without the power to create duplicate memberships.