It's been ages since I put this code together so my memory of it may be shacky ... I guess I am saying 'try it and see'.
To your 2nd questions, IIRC, you will not have a problem changing a units name ... your 2nd melee unit will totally ignore what you renamed the first one.
Re your first question ... if you are counting over combat type (ie melee), then it will increment the counter if you build a warrior, axe, sword or spear - it doesn't care. If you want to use a different naming convention for spears, you will have to use the 'advanced naming' option and specify it as required (it breaks it down into ERA and Combat Type) - you will have complete control over 'Bgd' or 'Anti-Mount', etc.
Either way, if you build (say) warrior, axe, axe, archer, spear, warrior, axe and you are looping (counting) over combat type ... they will have names like:
warrior #1
axe #2
axe #3
archer #1
spear #4 <- 4th melee unit
warrior #5
axe #6
To get the spear to be '1st' you will need to count over unit - but then your axe will be #1, etc.