A mayor scale is harmonized using triads using the pattern 1-3-5.
As you probably know, that's only *a* rule - often suggested to beginners who are learning how to harmonise. It's certainly not the *only* rule you can use (if you even want to use a 'rule' at all!). For example...
- You could use some chords with more than 3 notes, or construct harmonies with less than three notes
- Even if your melody follows the major scale, It's possible to underpin it with chords outside the major scale
- It's not necessarily true that all triads from the major scale will subjectively sound good in every context. Many musical styles will avoid the diminished vii chord, for example.
Even so, it's fair to say that using the set of triads built by stacking thirds on the root of each degree of the scale is often suggested as an idea that often 'basically works'. So, can that work with any scale?
The answer is no, for a fairly trivial reason : not all scales have enough notes in to allow you to build a triad from thirds on each root. Take the pentatonic scale C D E G A, for example - you can build a triad from thirds on C and A, but not on the other degrees of the scale.
You also ask what are the principles for harmonizing any scale?, but that would take a book to answer (and people have already written many better books than I could!). Coming up with a set of possible chords based on the notes in a scale (and then using only that set of chords within a piece, or a section of a piece) is only one of many possible techniques for creating harmony.