That could be because the contact you're trying to lock on is not currently reflected by your own radar, but a datalink contact sent from another donor. Basically, it's not a radar contact, otherwise you could just click on it for an instant lock. That could be because the enemy is not inside your radar scan area, since you're using 2B sweep. This is why I prefer 4B with a 80 degree horizontal arc. Also, you say that it happens right after you engage a target, so I take it that the new target you're trying to lock is quite close. The closer you are to a target, the smaller is your radar scan area.
Instead, since there's "nothing there" for your radar, it starts searching for possible contacts in a tight arc while still using the 2B sweep. It will lock into the first contact it finds no matter the range, but it won't find the enemy plane in the first place if it's still outside the 2B sweep cone.
This is why I often use the Situational Awareness page to check the altitude of datalink contacts, it allows me to set the correct radar elevation when trying to get a lock. It's especially useful when the contact is really close, because the radar is almost useless at that range without the ACM on. You can use the "step" button in SA to lock the SA slew to a target, so that you can always see the contact's altitude at a glance.