Can I ask why you are trying to do this with an eVar instead of the Products List which is designed to pass multiple products with their own contextual merchandising eVars?
I can think of no way to properly split an eVar to get you what you want (short of taking it outside of Adobe, and processing it with another tool).
However, using Products List will do exactly what you want without trying to do a solution after the fact.
The notation of Products List for each item is:
category; product identifier; quantity; price; merchandising events; merchandising eVars
Each item should be separated by a comma delimiter... think of this as a list of lists.
Quantity and Price only apply when the "purchase" event is present on the call, but you cannot access these independently.. these build the revenue metric (quantity multiplied by price). So if you want an item count you can use, I would use a numeric event as well in the notation (see below). All of the fields are technically optional except for the product identifier...
For more info see:
https://experienceleague.adobe.com/en/docs/analytics/implementation/vars/page-vars/products
So let's look at a simple example, just the products, and I am going to use event1 as my "items count"
Your first example: prodA,prodB
s.events = "event1";
s.products = ";prodA;;;event1=1,;prodB;;;event1=1";
This will count prodA once, and prodB once... if this were a purchase event, I might update it to something like this:
s.events = "event1,purchase";
s.products = ";prodA;1;9.99;event1=1,;prodB;1;4.99;event1=1";
Now, let's look at your second example: prodB,prodB,prodB
to something like this:
s.events = "event1";
s.products = ";prodB;;;event1=3";
This will count prodB three times.
Now, let's take this a step farther, let's say the you want to track some extra info about your products... like maybe you need to track the type and the colour. I am going to assume that "prodB" is a SKU and therefore has a specific designation for each colour. eVar1 will be the type, and eVar2 will be the colour.
s.events = "event1";
s.products = ";prodA;;;event1=1;eVar1=t-shirt|eVar2=red,;prodB;1;4.99;event1=1;eVar1=pants|eVar2=black";
When you break your products down by the eVars, "t-shirt" will only map to prodA (not to prodB), the same with "red", it only applies to prodA... and pants/black will only map to prodB
While these are eVars, once you turn these into Merchandising eVars the context of the specific product they are paired to applies.