I have searched for similar question like Accidentally added other's commits to my PR using git rebase. The answer for that just provide a method to remove unwanted commit from pr, but I still don't know why this happen.
These are commands to reproduce my problem, but I'm not sure for others.
>>> (main) git log --oneline --graph -5
* fa9a315
* e52240c
* 25c40fb
* 9ceb4b0
* ed40e2c
>>> (main) git checkout ed40e2c
>>> (@ed40e2c) git switch -c test-rebase
>>> (test-rebase) echo "foo" >> ./test.txt
>>> (test-rebase) git commit -am "test message"
>>> (test-rebase) git push -u origin test-rebase
>>> (test-rebase) git branch -vv | grep test-rebase
* test-rebase 6c0f33e [origin/test-rebase] test message
>>> (test-rebase) // create a pr in GitHub
>>> (test-rebase) git rebase main
>>> (test-rebase ⇣1⇡5) git pull -r
>>> (test-rebase ⇡4) git push
>>> (test-rebase) // now my pr has other's commits, and I'm also the coauthor of those commits
>>> (test-rebase) git log --oneline --graph test-rebase origin/test-rebase main origin/main
* 8bd227f (HEAD -> test-rebase, origin/test-rebase) message-4
* 938935c message-3
* 4080d9d message-2
* 8dbd5cd message-1
* 6c0f33e test message
| * fa9a315 (origin/main, origin/HEAD, main) message-4
| * e52240c message-3
| * 25c40fb message-2
| * 9ceb4b0 message-1
|/
* ed40e2c