How to execute a fill command when a player is on a specific coordinate?

/execute @a x y z /fill x y z x y z redstone_block

Here was your old trials. I'm assuming you were testing for players on coordinates (1, 2, 3) by doing:

/execute @a 1 2 3

But no. What exactly are the coordinates after @a doing? Let's take a look.

From the Minecraft Wiki:

Syntax

execute <origin: target> <position: x y z> <command: command>

And what does the coordinates do?

Specifies the position from which to run the command. Coordinates specified with tilde and caret notation are relative to the target, not to the position of the command's execution.

Your command is telling Minecraft to do this:

Tell all players to execute the following command at x, y, z: fill x1 y1 z1 x2 y2 z2 redstone_block.

Obviously not what you want.

To filter players based on position, properties, distance, etc., you have to modify @a to include arguments, which will filter your selection to the correct players.

Arguments go in the (optional) square brackets after @a. For example: @a[ARGS]

We'll use the x, y, and z arguments to select a position, and the r argument to dictate how close the player must be.

/testfor @a[x=1,y=2,z=3,r=5]

For example, this command will succeed if a player is detected within 5 blocks of (1, 2, 3).

All you need to do is place a chain command block after that set to conditional mode, with the command you want to run, like your /fill or a /setblock.