The vowel is originally short, as in the preposition and most instances of the prefix.
Any vowel before NS or NF becomes long, and this causes the S-initial forms of esse to lengthen the vowel of the prefix.
You can observe the same pattern in the prefix in- before words starting with S or F, but it's certainly most striking with esse which varies its initial letter.
One can argue that the vowel being marked long is merely a typographical convention.
Namely, in typical classical pronunciation a syllable ending in an N before an S has its vowel lengthened and nasalized and the consonant is lost.
Not all conventions in all times and places do this, so the macron may or may not make a difference depending on how you pronounce Latin.
A nasal disappearing and leaving the preceding vowel nasalized and long is not uncommon, but the exact scope of this phenomenon is beyond the scope of this question.
The practical answer is that the vowel quantities are as you found them to be due to the simple rule given in my first paragraph.