How to edit the label of an existing address exactly like in bitcoin-qt but instead using RPC calls? I am trying to edit the label of a bitcoin address in my wallet outside of bitcoin-qt. Currently I only know of 'setaccount' but it results in two addresses after editing one, it assigns a new address to the old label for some reason?

Does anyone know if there is a way to accomplish my goal?
accounts are groups of addresses and the label you see is the name of an account. you may list this with rpc listaddressgroupings. a key that you "relabel" with setaccount will be "moved" to the account with the new label but all other addresses stay with the other account. of course you may move all addresses to another account. basically an address can only belong to one account at a time, not vice versa.

also see How do you delete an account in Bitcoin Core?