This is the kind of thing that I specialize at. Ie, using the keyboard and mouse to do things in apps.
However to be honest, I expect AppleScript support is built-in to Keynote, and therefore there's probably a more correct way to do it than the way I would do it.
Using the keyboard and mouse, there are multiple ways to solve this problem. I will choose one of the ways that I thought was easiest, but there could be other solutions that are easier than mine. My method may differ from the way you do it now. And my method may make certain assumptions, for example, that you aren't using MacOS "Dark mode". If any of my assumptions are wrong, we'll probably find out soon enough.
You didn't mention what colour you choose so I'm going to have to guess that too.
The first step in my solution is to click on the Shapes button in the Keynote toolbar. I would do it with something like this:
I can't upload this action for you because it contains an image in the Image Box and my screen resolution may be different from yours so my action would never work for you. You would have to create this action manually yourself. The Image Box in this case contains an image of the three buttons at the top: Text, Shape, Media. I use all three for a specific reason that has to do with increasing the likelihood that this macro will work. For now, just trust me that using three buttons in that box is probably for the best.
Then you will use this action to make sure that the stop sign appears. This may be an optional step, for reasons I won't get into, but it's best to do this:
Then you need the following action. This works for me, but you might have to adjust it if it doesn't click on the stop sign icon that appears. There are other ways to do this, but this seems to be the most reliable for me.
At this point I don't really know what you want to do, but if all you want to do is change the colour to red, this should suffice:
You may not be able to see it, but I included a white frame around (three sides of) the red square, which I got be taking an image of the red box in the style menu on the right side of Keynote. Using some white space around the red square is essential. You must take this advice, or you may have lots of problems. I'm willing to explain if you want, but for now just trust me.
Taking screenshots is the trickiest part of using this approach. I won't blame you if you ask lots of questions about this. I'm happy to answer.
if I misunderstood what you wanted to do, tell me what I did wrong. I'm happy to make changes.