:s[ubstitue] command operates on whole lines and the
[range] prefix is a range of lines.
To restrict the operation to just the visually-selected region, you can use the
\%V atom in your search pattern. That is, visually-select the first two 1s in your example, then use this command to replace just those 1s:
:help entry says to put
\%V at the start and end of the pattern, but I didn't read that before trying it and it worked in the example here with
\%V at just the start of the pattern.