When we want to find the total charge of an object or total mass, usually we start off with a setup such as:
$$ m = \int dm \:\;\:\text{or} \:\;\:q = \int dq$$
in which we then use (and to keep it simple lets imagine the object is a rod) a substitution using linear mass/charge density for our differential:
$$ dm = \lambda dx \:\;\:\text{or} \:\;\:dq = \lambda dx$$
That's all totally fine with me and calculations are no problem. But I usually like to over analyze things and then I started to question the $dm$ and $dq$. Is each $dm$ and $dq$ piece even if the rod has a density that is non-uniform? In calculus, when integrating something like $dx$, each piece can be regarded as infinitesimally sized but they should all be the same width no matter which piece you pick. But for $dm$, for example, I started to have the thought that each piece of $dm$ are unequal to each other. Since we can change $dm \to \lambda dx$, we can imagine taking a small piece of $x$ ($dx$) and analyzing $\lambda$ at that point. And if the rod has its mass non-uniformly distributed wouldn't that mean that all $dm$ pieces are uneven as $\lambda dx$ will output a different value each time or rather, $\lambda dx$ will output a different value of $dm$ each time.
And I figured that's maybe one of the reasons why we make the density substitution as we need to integrate something that has even pieces like $dx$.
This might be me overthinking it and maybe its more of a math question but any opinion if this is logical thinking would be of great help.