First off, are you sure you need to add actual content to your buffer? If the goal is just to get it the same height as a single, current window, there's a much simpler method in normal mode:
Or in Vimscript:
The problem with your append command is that you're passing a string, which explicitly tells it add the content to a single ...
Use _u to open last buffer,_U to view last buffers.
It can be improved.
let g:lastWindows= 
let g:lastWinName = ""
if &bt == '' || &bt == 'help' || &ft == 'netranger' "|| &bt == 'nofile'
let cur= expand( '<afile>' )
if cur == g:lastWinName || cur ==""