How do you know if a piece is in a major key or its corresponding minor? As far as I can tell, the key signature is the same. Maybe it doesn't matter as they are the same, just starting 3 half steps behind or does it? Has it got to do with the first note on the first bar? Also, Same question applied to which mode am I in!
It will depend somewhat on whether you're talking about the dots, or listening to something being played. Yes, the key sig. is the same (Amaj./F#m both have 3#). but also present in the dots, more often than not, will be a raised leading note, here it'll be E#, in the relative minor, F#m.
Listening, you'll usually find a place where the piece seems to be 'home'. That's always a good clue. The first bar chord is often a clue, but the last chord is more decisive. There are quite a few tunes, however, that come under the category 'undecided',as they modulate back and forth, and does it really matter?
Mode wise - let's say we're in D Dorian, second mode of C major. As it's a minor mode, with no leading note a semitone under the root ( now D), it's more tricky, but again, there's that feeling of 'could we stop at this point, and feel happy that we've arrived home, and teh piece could stop'. It is more awkward, because there will always be that subtle pull towards the parent root, as the harmonies tend to be heard to gravitate.
The "first note" rule, while a good one to explore for beginners, often falls short, as not every tune starts on the 'tonic' (or 'key signature note'). In most cases, Major keys are pretty distinguishable from minor keys. I would do some exercises to train your ears to hear tonic chords in major and minor. This can be as simple as playing through all the chords in the key of C Major (for example), and then A minor (the relative minor). You might move on and try some chords progressions in various orders - for example FMaj, Dm, C Maj - always ending on the tonic (C Major in this case) so your ears hear the resolution. Then, perhaps try the same progression in the minor key relative to scale degrees you did in the major key. So in C Major: Fmaj (IV), Dm(ii), C Maj (I). In A minor: Dm (iv), Bhalf dim7 (ii), A minor (i). Regardless of the progression, you should hear the tonic, ending "home" sound. Of course, the ii-V-I in major (Dm, G7, C) and ii-V-i in minor (Bdim, E7, Am) will give you more pronounced tonic resolution.