In both of these sentences, the part after the comma is a participial phrase: being is the (present/active) participle in the first sentence, and affected is (past/passive) participle in the second sentence.
The participial clause serves as an adjective that applies to a noun in the sentence, to provide essential (defining) information or non-essential information.
The people affected by the gas leak were taken to hospital - defining: only those people that were affected were taken to hospital.
The people, affected by the gas leak, were very annoyed. - non-essential - all of the people were annoyed, and the reason is that they were affected by the gas leak.
Both of your sentences are grammatically correct, but they somehow don't seem natural. The main problem is that the meaning in both cases is far from clear. In part, the problem comes from the original sentence.
when means when something is happening, and not at any other time. "when choosing a certain brand" - means that when somebody is in the process of choosing to buy some unspecified brand, they are affected by some unspecified agent (possibly advertising) in some unspecified way, but when they are in the process of choosing a brand other than the unspecified brand, they are not affected.
My guess is that the intended meaning is that advertising affects the choice of brand. This would be better expressed as
advertising affects only their choice of brand.
Note that only should go as close as possible to what it applies to - "their choice of brand", rather than before "affects".
To use it as a participial phrase, you could say
People will buy such goods anyway: advertising does not affect their decision to purchase, affecting only their choice of brand.
You can now see the real problem with both sentences: the participial phrase is not defining, nor is it non-essential- it's the opposite of the meaning of the main clause. This can be presented far more clearly and simply as a parallel sentence:
People will buy such goods anyway: advertising does not affect their decision to purchase, only their choice of brand.