Org mode version: 9.4.6
... but the problem is older:
Reproduce:
1. Open org-agenda
2. Open a task from the agenda in the other buffer (i.e. the org file)
3. In the org file, move the cursor away from the task's headline
4. Focus the same task in the org-agenda again
5. Press C-c C-q (org-agenda-set-tags) and select some tags
The tags are not appended to the task's headline but to the line the
cursor was.
Example:
I'm in org-agenda and press C-c C-q, select "test" as tag. The result is:
** TODO Update libxxx on AUR
SCHEDULED: <2020-09-20 Sun> :test: