How are these plurals derived? [duplicate]
It would be difficult to give a complete answer to this question. (I suspect that will result in this question being quickly closed by the English StackExchange Nazis.) English has many rules for how word endings are changed when a suffix is added or words are combined.
In this case, if a word ends in a "y", and that "y" is preceded by a consonant, then when we add an "-s" we change the "y" to "ie", when we add "-ed" we change the "y" to "i". If the "y" is preceded by a vowel, it is left unchanged. Thus "boy" becomes "boys", "key" -> "keys", "play" -> "played", but "story" becomes "stories", "company" -> "companies", "party" -> "partied". Etc.