I landed here searching for a written solution regarding icon embedding in the output assembly/executable. But this accepted answer is not really explaining anything, unless you know how the answer relates to the code as a concept. For the code part, the link given by Jonas died in meantime as well.
Set as embedded resource
But another way is to set the icon file (which is preferably) in your solution as embedded resource by right click on the icon file in your solution. And set the field 'Build Action' to 'Embedded Resource'. Default it is set to 'Content', which makes the icon file appear as a separate file in the bin/output folder.
Then load the icon from the assembly/executable file at runtime by code. This is slightly different code than the idea Jonas probably meant to link (as he refers to resources in the project properties).
Usings for code below are
using System.Drawing;
using System.IO;
using System.Reflection;
//note: this = the current windows form I'm setting the icon for, in my case.
var assembly = Assembly.GetExecutingAssembly();//reflects the current executable
var resourceName = $"{this.GetType().Namespace}.{this.ProductName}.ico";
//note: this.ProductName reflects the executable's Product name in my solution (see current project, right click it, then click: properties - application - assembly information)
//reading the source / icon file, in this case from the assembly (as the icon is embedded in here), but the icon can be loaded from anywhere at this point.
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
{
this.Icon = new Icon(stream);
}
And to have a correct icon displayed on the shortcut or taskbar, make sure the icon file contains several sizes (variating from 48px by 48px to 256px by 256px). Else it shows a resized/upscaled icon.
Set icon on application property level
At last, set the icon for the project by clicking right on the project (in solution explorer) and then click: properties - application. Here at 'Resources' pick the .ico file in your solution. As it's embedded in the assembly this way, it won't need a copied version in the bin / output folder. But I assume the output assembly now includes two icons, one as embedded resource and one somewhere hidden in the assembly's bytes... as leaving out one of them breaks icon displaying functionality showing a default icon or not loading the embedded resource icon. The benefit of this answer is, as input, there is only one icon file, which is best for maintaining it.
Possible glitch on your machine is icon caching by Windows
Possibly, the machine's icon cache can be an issue. This mostly is occurring when developing the application and switching icons, displaying a former/previous icon. Search the internet for "reset icon cache windows", or this example here https://www.windowscentral.com/how-reset-icon-cache-database-windows-10.