Let $r$ be the radius & $h$ be the height of the cylinder having its total surface area $A$ (constant) since cylindrical container is closed at the top (circular) then its surface area (constant\fixed) is given as $$=\text{(area of lateral surface)}+2\text{(area of circular top/bottom)}$$$$A=2\pi rh+2\pi r^2$$
$$h=\frac{A-2\pi r^2}{2\pi r}=\frac{A}{2\pi r}-r\tag 1$$
Now, the volume of the cylinder $$V=\pi r^2h=\pi r^2\left(\frac{A}{2\pi r}-r\right)=\frac{A}{2}r-\pi r^3$$
differentiating $V$ w.r.t. $r$, we get $$\frac{dV}{dr}=\frac{A}{2}-3\pi r^2$$
$$\frac{d^2V}{dr^2}=-6\pi r<0\ \ (\forall\ \ r>0)$$
Hence, the volume is maximum, now, setting $\frac{dV}{dr}=0$ for maxima $$\frac{A}{2}-3\pi r^2=0\implies \color{red}{r}=\color{red}{\sqrt{\frac{A}{6\pi}}}$$
Setting value of $r$ in (1), we get
$$\color{red}{h}=\frac{A}{2\pi\sqrt{\frac{A}{6\pi}}}-\sqrt{\frac{A}{6\pi}}=\left(\sqrt{\frac{3}{2}}-\frac{1}{\sqrt 6}\right)\sqrt{\frac{A}{\pi}}=\color{red}{\sqrt{\frac{2A}{3\pi}}}$$
Hence, the ratio of height $(h)$ to the radius $(r)$ is given as
$$\color{}{\frac{h}{r}}=\frac{\sqrt{\frac{2A}{3\pi}}}{\sqrt{\frac{A}{6\pi}}}=\sqrt{\frac{12\pi A}{3\pi A}}=2$$ $$\bbox[5pt, border:2.5pt solid #FF0000]{\color{blue}{\frac{h}{r}=2}}$$
You don't say so explicitly, but your formulas imply that the
symbol $r$ represents the radius of the cylinder and $h$ is the height
of the cylinder.
There are many differently-shaped cylinders that can fit inside a
given sphere. If the radius of the sphere is $6$,
near one extreme, you have a very skinny cylinder whose
height is very close to $12$ and whose radius is close to zero.
Near the other extreme, you have a cylinder that is almost a flat disk
with a very small "height" (or thickness) $h$ and a radius that is
barely less than $6$.
We can even take the cylinder all the way to the extreme where it is
only a degenerate cylinder: $h=12$, $r=0$ describes a line segment that
just exactly fits in the sphere, and $h=0$, $r=6$ describes a flat disk
that also exactly fits in the sphere.
There's not much point in considering $r < 0$, because what is a cylinder
with a negative radius? (Actually there is a way to interpret such a thing,
but if you allow, for example, a cylinder of radius $-2$, it's identical to
a cylinder of radius $2$; so you have found no new cylinders but you have
to rewrite formulas such as $A(r) = 2\pi rh$ because the lateral area
of a cylinder is not less than zero. It's easier, and we don't miss
any answers, if we consider only cylinders such that $r \geq 0$.)
There is certainly no point in considering a cylinder with radius $r > 6$
if the radius of your sphere is $6$, because there is no way such
a cylinder could possibly fit inside the sphere.
You could also come to these conclusions by examining the formula
you found,
$$A(r)=2\pi r \cdot 2\sqrt{36-r^2},$$
because $r < 0$ gives a negative area (which can't be correct)
and $r > 6$ asks you to take the square root of a negative number,
which doesn't work.
But I think it's a good idea to have reasons based in the original
problem statement that say why a variable $r$ should have only a certain
possible set of values, because there's no guarantee that every
restriction that the problem statement requires will also be
enforced by whatever formulas we derive.
So we are OK with $r=0$ (if we accept a line segment as a degenerate cylinder of radius zero), we are OK with $r=6$ (if we accept a circle as a degenerate cylinder of height zero), and we are OK with
anything in between--just set $h= 2\sqrt{36-r^2}$, as you discovered,
and the cylinder will fit perfectly.
But $r < 0$ is useless to consider and $r > 6$ is impossible.
So $0 \leq r \leq 6$ describes every cylinder that we could ever want
to inscribe in a sphere of radius $6$.
Best Answer
Take a piece of clay and roll it into a cylinder. Say it has length $\ell$ and radius $r$. Then its volume is $\ell\cdot \pi r^2$. And its surface area (not counting the two ends) is $\ell\cdot 2\pi r$.
Now roll out your cylinder so that it becomes longer and thinner. Say it's only half as thick as before, the radius has decreased to $\frac r2$. But of course the volume must be the same because the amount of clay is the same. Since the $\pi r^2$ is one-fourth as big, the length must be four times as big to make it work out. The cylinder is half as thick, but four times as long.
That means that the new surface area, $4\ell\cdot 2\pi \frac r2$, is twice as large as it was. Which makes sense: the cylinder is longer and thinner, so more of it is at the surface.
Now roll it to be half as thick again. The volume is still the same, but again the surface area doubles. Think about how quickly a thin clay snake will dry out, compared with a thick chunky cylinder. Why? Because it has so much more surface area for the same volume of clay.
You can keep rolling the snake, and increase the surface area as much as you want. You can't maximize the surface area, because you can always double the surface area by rolling the snake to be half as thick and four times as long.
(Other examples to consider: You can take the same clay cylinder and smear it into a thin flat sheet that covers the whole earth. Its surface area will be the same as the earth's! But its volume is the same as it always was.
A kitchen sponge has a small volume, but a very big surface area. As you add more holes to the sponge, the surface area increases even though the volume of the sponge is getting smaller.)
It's important to notice that at no point does the snake have an infinite surface area. We can roll it out as thin as we like, and make the surface area as large as we like, but it's always a snake with finite length and finite surface area. What if the radius of the snake goes all the way to zero? Well, that doesn't really make sense. It's not a cylinder any more, it's a line, and a line doesn't have a surface area.
But we can use this rolling process to make a shape that does have an infinite surface area! Start with the same cylinder, and instead of rolling out the whole thing to be half as thick, roll out just the right half, leaving the left half the way it was. The left half's surface area stays the same, and the right half's surface area doubles, so the total surface area has increased from $\frac12+\frac12$ to $\frac12 + 2\cdot\frac12 = 1.5$. The surface area has increased by 50%, and in particular the right half has as much surface area as the original cylinder.
Now take just the right half (which is now just as long as the original cylinder was) and roll out its right half. Again the volume of the part we roll out doubles, so the total surface area now goes from $\frac 12 + \frac12 + \frac12 $ to $\frac12 + \frac12 + 2ยท\frac12 = 2$.
We can keep doing this as long as we like, making this spindle thing longer and longer, and again we can make the surface area as large as we want. But this time it's a little different than when we rolled the whole snake. There, to make the snake infinitely long, we would have had to make its radius go to zero, and then we wouldn't have a solid figure any more. But no part of the spindle has a radius of zero. It gets thinner and thinner as you go along it to the right, but every part of it has a positive, nonzero thickness. So you can take the spindle all the way to infinity, and then it has an infinite surface area, but its volume stayed the same the whole time.
This spindle is Gabriel's Horn.