05AB1E, 18 17 bytes
Dª€gà©nи®ô¹ì²ζø®∍
Try it online or verify all test cases.
Explanation:
D # Duplicate the first (implicit) input-matrix
ª # Append the matrix to itself
€ # Map over each inner list:
g # Pop and push its length
à # Pop and push the maximum
# (we now have the dimension of the output-square, which is either
# equal to the amount of rows or amount of columns, whichever of
# the two is larger)
© # Store this maximum in variable `®` (without popping)
n # Square it
и # Repeat the second (implicit) input that amount of times as list
®ô # Split it into parts of size `®`
¹ì # Prepend the first input-matrix at the front
ζ # Zip/transpose; swapping rows/columns,
² # using the second input-character as filler
ø # And then zip/transpose the rows/columns back
®∍ # Shorten the matrix to the first `®` amount of rows
# (after which the resulting matrix is output implicitly)