The main rule for vowel length in English monosyllables is allophonic: it's not based on any inherent feature of the vowel itself, rather it's completely based on the surrounding sounds.
Different vowel phonemes also have tend to have different lengths, but as far as I know much of that variation is based on general phonetic principles and it wouldn't be necessary for a learner to focus on it (unless you're learning British English, where length can be an important factor for differentiating the vowel sounds in "bed" and "bared" or "bid" and "beard" respectively, or Australian English). Vowel quality is much more important than length for distinguishing such similar pairs of vowel phonemes as /ɪ/ and /i/ or /ɑ/ and /æ/.
The English allophonic vowel length rule
Before a voiceless consonant, a vowel will be pronounced fairly short.
When a vowel comes at the end of a word or before a voiced consonant, it will be pronounced fairly long.
While this is automatic and not really noticed by native speakers, it is good for learners to be aware of this rule because applying it will make it easier for native speakers to understand which word-final consonant you are using. If you use an extremely short vowel in a word like "cad", it may be misheard as "cat". Conversely, if you use too long a vowel in "cat", it will be prone to being misheard as "cad".
The phoneme /æ/ does have relatively complicated development in different accents. It is prone to splitting into two variants.
Some dialects have extra lengthening of /æ/ in certain, but not all words ending in voiced consonants; typically the set includes "bad, mad, sad" as well as some other words (which exactly is not fixed). This shows up in certain British accents, but the only major variety of English where it is established is Australian English. As far as I know, few learners focus on learning this accent, so I think this split can and should be ignored by the vast majority of ESL students.
In North America, /æ/ tends to have a "tensed" variant in some contexts; phonetically, this means it is fronted and raised to something like [eə̯].
This is generally still kept distinct from /eɪ/ (the only context I know of where they may merge is before /g/), and as far as I know it is always kept distinct from /ɛ/. So I don't know if it's all that useful for a non-native speaker to aim to produce this tensed variant: if you use /æ/ in all contexts, it will usually still be understandable, while if you try to produce tense a you might risk having it mistaken for /eɪ/ or /ɛ/.
As Wikipedia summarizes there are a number of different systems used; the one I use (which I believe is relatively common) is the "nasal system" where [eə̯] occurs only and always before the nasal consonants /m n ŋ/. So I would pronounce "rat" as something like [ɹæˀt] (I'm using [ˀt] to represent pre-glottalized /t/), and "ran" as something like [ɹeə̯n]. "Rad" would be something like [ɹæːd̥].