The Gradient tool doesn't work exactly the same as the paint bucket tool in Photoshop (it's more for direction control). You just need to select the area you want to apply the gradient to first.
Ctrl + Click (or CMD + Click if you're on a Mac) on the thumbnail of the layer that has your brush strokes to create a selection based on that shape, then use the gradient tool to apply the gradient in that area only.

How to fill in an area with a gradient in Photoshop? - Graphic Design Stack Exchange
A quick way to create a smooth-colorful gradient in Photoshop
Photoshop 2023: Cannot directly edit gradients anymore?
I seem to be the only one who hates the new gradient tool...
Solved.
Apparently you just have to change the tool to "Classic Gradient". Then, for colors, change Method to classic as well.
More on reddit.comVideos
The Gradient tool doesn't work exactly the same as the paint bucket tool in Photoshop (it's more for direction control). You just need to select the area you want to apply the gradient to first.
Ctrl + Click (or CMD + Click if you're on a Mac) on the thumbnail of the layer that has your brush strokes to create a selection based on that shape, then use the gradient tool to apply the gradient in that area only.

While Vicki's answer helped you get the results you might want to start learning about Layers and the benefits they offer. Since you mention using the Paint Bucket tool it sounds like you're working on a single Layer.
So you probably have something like:

Ideally, you'd instead want them to be on a new Layer, like this:

But, let's say you have something you really like and don't want to start over so I'll use the case of the first one in the rest of this. Like you discovered you can Paint Bucket the inner areas. Likewise you can select areas to fill with gradients. Let's take that a step further.
- Select the areas you want to have the gradient:

- Create a new Layer using Shift+Ctrl/Cmd+N or the 6th button from left on the bottom of the Layer Window

- Now fill it with the
Paint BucketorEdit > Fill(Shift+F5

- Now the magic happens by added a Gradient Overlay:


The Benefits
Let's say shortly after doing that you want to change the Gradient, then double click on the Gradient Overlay effect in the Layer Window and you can change it:


Let's say now you're working and want to add another area with the Exact Same Gradient. Well just add it to the Layer portion using a Brush or Select/Fill and anything you add on the Layer will pick up the Gradient Overlay:
