This is because
last-kbd-macro is a terminal-local variable.
(elisp) Multiple Terminals
There aren't a large number of such variables in Emacs, so it's easy to get caught out by the fact that they exist at all, but also very helpful to be aware of the concept, as it helps you to jump to the correct conclusion in such situations.
Note that C-hv
last-kbd-macro helpfully points out that it is terminal-local. (Obviously you would need to know where to look for that in the first place, but it gives you confirmation if you do.)
What you would want to do in this situation is either name the keyboard macro and call it by name, or assign it to a key and then use that key binding. You can read about those abilities in the manual:
(emacs) Save Keyboard Macro