Not only the ID but the old username also remains, as only the display name is changed meaning you can only log in the forum with the old username and not with the new display name if I'm not wrong.
In most cases, your post is accurate but in some few cases, usernames were changed too and only UID remains intact.
theymos wrote it clearly.
Each user has a display name, which is the only name ordinary users see, and a username, which is what you use to log-in with. Almost always, they are the same.
If I change a name for reasons of appearance, then I only change the display name. The username remains reserved, the user can still login using the username, PMs can still be sent to that username, "search member" allows searching for the old username, etc.
If I change a name for reasons of privacy, then I change both the username and the display name. In this case, it is possibly hazardous to reserve the old username, since it allows someone to test for the existence of that username, possibly defeating the privacy benefit. If you're worried about being impersonated, then simply don't seek to have your username changed.