I have run your code and verified the contents. When the number of data exceeds 1000 in a scatterplot, it changes to scattergl, which is a scatterplot for large amounts of data, instead of the normal scatter, see here for more information about scattergl. My guess is that is the cause. If you rewrite each chart in a graph object, the overlap is the same even if the number of data is 1001.
import plotly.graph_objects as go
import numpy as np
import pandas as pd
n_row = 1001
df_1 = pd.DataFrame({'x': np.random.rand(n_row), 'y': np.random.rand(n_row)})
df_2 = pd.DataFrame({'x': np.random.rand(20), 'y': np.random.rand(20)})
fig = go.Figure()
fig.add_trace(go.Scatter(
    x=df_1.x,
    y=df_1.y,
    mode='markers',
    marker=dict(color='red', size=4)
))
fig.add_trace(go.Scatter(
    x=df_2.x,
    y=df_2.y,
    mode='markers',
    marker=dict(color='Blue', size=20)
))   
fig.show()
