This clause clarifies that the names of contributors cannot be used to promote versions of the software that they didn't author.
For example, consider an imaginary Xunil operating system authored by a well-known Tinus Lorvalds and published under BSD-3-clause. I can now freely go around and give (or even sell) to other people copies of Xunil and tell them that they can trust it because Lorvalds wrote it.
But under that license I cannot add my own modifications and then advertise my modified version as Lorvalds' work. For example, I might introduce bugs or backdoors into the operating system. Lorvalds is not responsible for them, I am. As far as the license is concerned I'm totally allowed to create and distribute my buggy insecure version, as long as I leave other contributors like Lorvalds out of my promotional efforts.
This does not modify the attribution requirements, that the copyright and license notice (including Lorvalds' copyright statement!) must be preserved in the source code and in documentation.
Neither of your scenarios is affected by this license term, because your “X” is the name of the software, not the name of the contributors. Of course you are allowed to mention that you used a certain software. Of course you are allowed to state that your modified version is based on X. Of course you can advertise your modified version.
Personally, I think this clause of the BSD license is usually superfluous because the aspects it prohibits may already be prohibited by personality rights. However, issues such as personality rights and trademarks differ substantially between jurisdictions, so that clarifying this issue in the license can have value.
In contrast to BSD-3-clause, the Apache-2 license only touches on trademarks, not on contributor names:
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
For example, if Xunil were Apache-2 licensed, and if there were a trademark on that name, then I wouldn't be allowed to advertise my buggy insecure version as “based on Xunil™”. But I would be allowed (and required!) to disclose this in the NOTICE file.