In the macOS Monterey Shortcuts Gallery, there are Shortcuts to “Tile Last 2 Windows”, “Tile Last 3 Windows” and “Tile Last 4 Windows”. This is my single combined version for any window (not just the last x).
My version prompts to select 2-4 windows:
If you only want to tile windows from a single app, can also completely automate the process, e.g. to tile Preview windows only:
Your mileage will vary: windows that enforce minimum dimensions don’t tile well.
At time of writing, Get Device Details simply does not provide correct Screen Height and Screen Width - be it via the dedicated action or via a built-in variable. In the first case, it returns zero, and in the second case, Shortcuts will show a very helpful “There was a problem running the shortcut” error: