Copying posts here from elsewhere can be allowed, but the rules of the other site must be followed.
Check the license that applies to the post on the other site. It probably requires attribution unless you are the author. Many sites let the author retain ownership, but you need to check to be sure before doing any copying.
That all said, while copying a post from elsewhere might be legal and not explicitly against the rules of either site, it's not necessarily a good idea. This is particularly true if attribution to the other site is required. That makes us look like we don't have our own content, and invites readers to go elsewhere.
Even when attribution is not required, a copied post can still cause problems. For one thing, it seems that search engines ding us for having copied content instead of original content. A few copied posts can hurt the whole site because random people searching for answers are less likely to find Codidact, even our home-grown content.
All in all, I think copied content should be discouraged. About the only exception that I think is OK is when you start with your own content elsewhere on a site that does not require attribution by the author. Even in that case, try to make the post here better than the original. Use the version on the other site as a rough draft, and go over it to fix spelling errors, awkward wording, perhaps include a diagram if appropriate, etc. We want Codidact to be where people end up when searching, and the answers here to be better than anywhere else. Copying not only fails to achieve that, but actually hurts it.