That’s a common gotcha. Keep in mind that Format-Table looks at the first object in the pipeline in order to determine what fields to display, and it generally expects to be piped a list of objects of the same type. When you run your script (and don’t assign the results to a variable), it’s implicitly piped to Out-Default, which decides to use Format-Table because the first object in the pipeline has only one property.
When you run each command by itself, you wind up with two calls to Out-Default / Format-Table, so you see both tables. Where you go from here depends on what you want your function to do. If it is just supposed to display this information at the console, and you aren’t worried about using this in a pipeline or saving the results to a variable, then just pipe each command to Out-Host: