How can I mirror my mouse and keyboard across multiple displays? I want to duplicate actions performed on my main screen on a second screen i.e. mouse clicks and keyboard input.

I have one iMac, with two similar displays. On both displays, I have opened two same programs with near pixel-perfect identical positions on the screens.

How can I achieve this? Does such a task require a programmer?

As an example:

Let's say, I open the Chrome browser, logged-in with my Google username ,on the main screen. On the screen display attached to my Mac, I open another Chrome browser window, this time logged-in as my friend's Google username.

What I want is for anything I do on the first browser (mouse clicks and keyboard) to be done on the second browser, on the second monitor.
This is not possible.

What you are attempting to do is mirror without mirroring.

Forgetting the secondary display for a second, you can't type or (mouse) control more than one window at a time.  It's the window that has focus that accepts input.  Think about it...you can move your mouse anywhere across any open windows, but you have to take focus of the window (click or hover depending on your settings) before you can interact with it.

Even moving the mouse in two separate windows is impossible.  Your mouse works on a coordinate system (X,Y).  You can see what it's (X,Y) value is by pressing CmdShift4 (screen capture).  There is no way to have a secondary coordinate value to "mirror" it on another window.

Adding another display won't help, either because unless you are mirroring the display (and since your example used different chrome browser profiles) you would be extending the display and the available (X,Y) coordinate system.