@mxyzplk has given a good answer. I agree that it's a good thing to inform the other party that you have an offer but you have to be vigilant. Based on personal experience, some potential employers see this as some sort of a game and try to turn the tables to their benefit.
I've recently been in this situation myself. Let me explain: I was looking for a new job and found a fitting job at companyA (good salary) so I applied.
CompanyB (excellent salary) contacted me because I've helped them out in the past and asked me if I could help them out for a half year. I said that I could not because I was only interested in a long-term agreement, so they asked if they could set up a talk with the CFO. The talk with the CFO was positive and he told me he would discuss it with the head of the board.
Meanwhile, I got an offer from companyA, so I told the CFO (companyB) that I got another offer. He told me that he would have his talk in 3 days, so I waited.
3 days later, no answer. So I asked the CFO if he knew something. He told me that they can agree to a contract of indefinite duration, with one month notice. I was already stretching the time to give companyA their answer, since they were kind of in a rush to hire someone. So, I told companyA that I found another job and won't be joining them.
In the meantime, I asked the CFO of companyB some questions because I thought it was kind of strange they wanted 1 month notice period in the contract. They told me they could only promise me work for 6 months with perhaps more after.
I was angry and told them I was fully honest with them and I will not join them this way. They replied back and said they may not have communicated well but they have been nothing but honest with me.
I was lucky to keep my old job since I already had told them I would be leaving. But that's another story.
Looking back, I believe their actions were deliberate to put me in a position where I had no choice.
The biggest mistake that I made here was that I gave indication to CompanyB that I would prefer to work with them. They tried to exploit this and succeeded.
What would have been better is If I told CompanyB that I have an offer from companyA and that I will accept it unless they have a better counter offer in 3 days, and stuck with it.
I'm still kinda shocked by how this all went down, but hopefully others can learn from this and not fall into the same trap as I did.